import { useReducer, createContext } from "react";
import App from "../App";

const initState = {
    count: 0
}
const reducer = (state, action) => {
    if (action.type === "increase") {
        return {
            count: state.count + 1
        }
    } else {
        return state
    }
}

const Context = createContext()
const Provider = props => {
    const [state, dispatch] = useReducer(reducer, initState)
    return (
        <Context.Provider value={[state, dispatch]}>
            <App />
        </Context.Provider>
    )
}

export { Context, Provider }

// export const Context = createContext();
// const Provider = props => {
//     const [state, dispatch] = useReducer(reducer, initState);
//     return(
//         <Context.Provider value={[state,dispatch]}>
//             <App/>
//         </Context.Provider>
//     )
// }
// export default Provider